package com.warlock.EternalBattle.assets;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class Graphics {
	public static Texture backgroundTexture;
	public static Sprite background;
	
	public static Texture miscTexture;
	public static Sprite mainMenu;
	public static Sprite gameOver;
	
	public static Texture condeTexture;
	public static TextureRegion[] condeRegion;
	public static Animation conde;	
	
	public static Texture loadTexture (String file) {
		return new Texture(Gdx.files.internal(file));
	}
	
	public static Animation loadAnimation(Texture texture, TextureRegion[] textureRegion, Animation animation, Float time,int FRAME_ROWS,int FRAME_COLS){
        TextureRegion[][] tmp = TextureRegion.split(texture, texture.getWidth() / 
FRAME_COLS, texture.getHeight() / FRAME_ROWS);                                
        textureRegion = new TextureRegion[FRAME_COLS * FRAME_ROWS];
        int index = 0;
        for (int i = 0; i < FRAME_ROWS; i++) {
                for (int j = 0; j < FRAME_COLS; j++) {
                	textureRegion[index++] = tmp[i][j];
                }
        }
        animation = new Animation(time, textureRegion);  
        return animation;                              
	}
	
	
	public static void load () {
		backgroundTexture = loadTexture("data/background/forest.png");
		background = new Sprite(backgroundTexture,0,0,512,256);
		
		miscTexture = loadTexture("data/misc/misc.png");
		mainMenu = new Sprite(miscTexture,0,0,320,240);
		gameOver = new Sprite(miscTexture,0,241,320,240);		
		
		condeTexture = loadTexture("data/entity/Conde/conde.png");
		conde = loadAnimation(condeTexture, condeRegion, conde, 0.002f, 3, 6);
	}
	

}
